import {reqSearchInfo} from '@/api'

// search小仓库
const state = {
    searchList:{}
};
const actions = {
    async getSearchList({commit},params={}){
        let result = await reqSearchInfo(params);
        if(result.code == 200){
            commit("GETSEARCHLIST",result.data)
        }
    }
};
const mutations ={
    GETSEARCHLIST(state,value){
        state.searchList = value;
    }
};
// 计算属性 - 在项目中为了简化仓库中的数据
// 把我们将来在组件当中需要用到的数据简化 - 方便我们在组件中获取数据
const getters = {
    // state 参数为当前仓库中的state
    goodsList(state){
        return state.searchList.goodsList || [];
    },
    attrsList(state){
        return state.searchList.attrsList || [];
    },
    trademarkList(state){
        return state.searchList.trademarkList || [];
    }
};
export default {
    state,
    actions,
    mutations,
    getters
}